{VERSION 6 0 "IBM INTEL NT" "6.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 1 }{CSTYLE "2D Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 256 "" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 0 }{CSTYLE "" -1 257 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 258 "" 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 259 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 260 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 261 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 262 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 263 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 264 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 265 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 266 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 267 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 268 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Tim es" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 } {PSTYLE "Title" -1 18 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 1 2 1 1 2 2 2 1 1 1 1 }3 1 0 0 12 12 1 0 1 0 2 2 19 1 }{PSTYLE "Normal" -1 256 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }3 1 0 0 0 0 1 0 1 0 2 2 0 1 }} {SECT 0 {EXCHG {PARA 18 "" 0 "" {TEXT 256 21 "Review Questions - 02" } }{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT 257 6 "Note: " }{TEXT 258 201 "Please answer the following questions to review Lectur e 2. You may need to try some Maple commands and answer the review que stions under the help of your lecture notes and the Maple built-in hel p menu." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 63 "1. What are the outputs of the three commands in the two \+ cases?" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 259 9 "Solution:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "restart:\nx=2:\nx;" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "restart:\nx:=2:\nx;\n" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 112 "2 . Write a program using a do loop that will print out the squares of \+ the integers n where n goes from 5 to 10." }}{PARA 0 "" 0 "" {TEXT 260 9 "Solution:" }{TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 181 "3. Write a do loop that goes from n = 1 to n = 100 and prints out those values of n that sati sfy 2*n^3 mod 11 = 3. You will need to use an if ... then print(..); e nd if; statement." }}{PARA 0 "" 0 "" {TEXT 261 9 "Solution:" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 107 "4. Write a pro cedure called f whose input is x and whose output is -1 if x < 0, 0 i f x = 0, and 1 if x >0." }}{PARA 0 "" 0 "" {TEXT 262 9 "Solution:" } {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 38 "5. What i s the output of the command. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 263 9 "Solution:" }{TEXT -1 0 " " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 47 "6. What is the mistake in the following command" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "a=5:b=10: \nif a " 0 "" {MPLTEXT 1 0 124 "ISPRIME:=proc(n)\n local k;\n for k from 2 to n-1 do\n if n mod k = 0 then return false end if: \n end do:\nreturn true\nend proc:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "ISPRIME(99);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }{TEXT 264 9 "Solution:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 52 "8. What i s the difference between the two sentences:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "x:='x':\ny:='y': \nx:=5; \ny:=2*x;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "x:='x':\ny:='y': \ny:=2*x; \nx:=5; " }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 266 9 "Solution:" } {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT -1 119 "9. Check whether the following procedure is correct or not, for computing the sum of all prime numbers between 1 and n." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 140 "SUM:=proc(n)\n local SUM, k ;\n SUM:=0:\n for k from 1 to n do\n if isprime(k)=true then \n SUM: =SUM+k \n end if: \n end do;\nreturn SUM;\nend proc:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 267 9 "Solution:" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 62 "10. What is the difference bwtween the fo llowing two programs?" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 97 "pr intlevel:=0:\nS:=\{\}:\nfor n from 1 to 10 do\nif n mod 2 =0 then S:=S union \{n\} end if; \nend do;\nS;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 97 "printlevel:=2:\nS:=\{\}:\nfor n from 1 to 10 do\nif n mod 2 =0 then S:=S union \{n\} end if; \nend do;\nS;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT 268 9 "Solution:" }{TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 119 "11. Write a procedure that will will sum all of the numbers from 1 to n if n is prime or re turn FAIL if n is not prime." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 85 "12. Write a pro cedure that will take a number n and caluclate the difference between \+ " }{XPPEDIT 18 0 "n^2 and (n+1)^2;" "6#3*$)%\"nG\"\"#\"\"\"*$),&F&F(F( F(F'F(" }{TEXT -1 1 "." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 135 "13. Using the procedure from 12, write a program that will run th is procedure for n = 1 to 10. What do you notice about these numbers? " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 256 " " 0 "" {TEXT -1 7 "- End -" }}}}{MARK "14 0 1" 0 }{VIEWOPTS 0 0 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 1 1 2 33 1 1 }